// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   register_draft_ok.java

package logistics.file;

import include.nseer_cookie.*;
import include.nseer_db.nseer_db_backup1;
import include.operateDB.CdefineUpdate;
import java.io.IOException;
import java.net.URL;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class register_draft_ok extends HttpServlet
{

	public register_draft_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			nseer_db_backup1 logistics_db = new nseer_db_backup1(dbApplication);
			if (logistics_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String fileKind_chain = request.getParameter("fileKind_chain");
				String chain_id = Divide1.getId(fileKind_chain);
				String chain_name = Divide1.getName(fileKind_chain);
				if (!chain_id.equals(""))
				{
					String provider_ID = NseerId.getId(getClass().getResource("").toString(), (String)dbSession.getAttribute("unit_db_name"));
					String logisticser = request.getParameter("logisticser");
					String logisticser_ID = request.getParameter("logisticser_ID");
					String provider_name = request.getParameter("provider_name");
					String provider_address = request.getParameter("provider_address");
					String type = request.getParameter("type");
					String provider_class = request.getParameter("class1");
					String used_provider_name = request.getParameter("used_provider_name");
					String provider_bank = request.getParameter("provider_bank");
					String provider_account = request.getParameter("provider_account");
					String provider_web = request.getParameter("provider_web");
					String provider_tel1 = request.getParameter("provider_tel1");
					String provider_fax = request.getParameter("provider_fax");
					String provider_postcode = request.getParameter("provider_postcode");
					String contact_person1 = request.getParameter("contact_person1");
					String contact_person1_department = request.getParameter("contact_person1_department");
					String contact_person1_duty = request.getParameter("contact_person1_duty");
					String contact_person1_sex = request.getParameter("contact_person1_sex");
					String contact_person1_office_tel = request.getParameter("contact_person1_office_tel");
					String contact_person1_home_tel = request.getParameter("contact_person1_home_tel");
					String contact_person1_mobile = request.getParameter("contact_person1_mobile");
					String contact_person1_email = request.getParameter("contact_person1_email");
					String contact_person2 = request.getParameter("contact_person2");
					String contact_person2_department = request.getParameter("contact_person2_department");
					String contact_person2_duty = request.getParameter("contact_person2_duty");
					String contact_person2_sex = request.getParameter("contact_person2_sex");
					String contact_person2_office_tel = request.getParameter("contact_person2_office_tel");
					String contact_person2_home_tel = request.getParameter("contact_person2_home_tel");
					String contact_person2_mobile = request.getParameter("contact_person2_mobile");
					String contact_person2_email = request.getParameter("contact_person2_email");
					String register = request.getParameter("register");
					String register_time = request.getParameter("register_time");
					String bodyc = new String(request.getParameter("invoice_info").getBytes("UTF-8"), "UTF-8");
					String invoice_info = exchange.toHtml(bodyc);
					String bodya = new String(request.getParameter("demand_products").getBytes("UTF-8"), "UTF-8");
					String demand_products = exchange.toHtml(bodya);
					String sqll = (new StringBuilder("select * from logistics_file where provider_ID='")).append(provider_ID).append("' and provider_name='").append(provider_name).append("'").toString();
					ResultSet rset = logistics_db.executeQuery(sqll);
					if (rset.next())
					{
						response.sendRedirect("logistics/file/register_draft_ok.jsp?finished_tag=0");
					} else
					{
						String sql = (new StringBuilder("insert into logistics_file(chain_id,chain_name,provider_ID,provider_name,provider_address,provider_class,type,provider_bank,provider_account,provider_web,provider_tel1,provider_fax,provider_postcode,used_provider_name,contact_person1,contact_person1_department,contact_person1_duty,contact_person1_sex,contact_person1_office_tel,contact_person1_home_tel,contact_person1_mobile,contact_person1_email,contact_person2,contact_person2_department,contact_person2_duty,contact_person2_sex,contact_person2_office_tel,contact_person2_home_tel,contact_person2_mobile,contact_person2_email,register,register_time,invoice_info,demand_products,check_tag,modify_tag,excel_tag,logisticser,logisticser_ID) values ('")).append(chain_id).append("','").append(chain_name).append("','").append(provider_ID).append("','").append(provider_name).append("','").append(provider_address).append("','").append(provider_class).append("','").append(type).append("','").append(provider_bank).append("','").append(provider_account).append("','").append(provider_web).append("','").append(provider_tel1).append("','").append(provider_fax).append("','").append(provider_postcode).append("','").append(used_provider_name).append("','").append(contact_person1).append("','").append(contact_person1_department).append("','").append(contact_person1_duty).append("','").append(contact_person1_sex).append("','").append(contact_person1_office_tel).append("','").append(contact_person1_home_tel).append("','").append(contact_person1_mobile).append("','").append(contact_person1_email).append("','").append(contact_person2).append("','").append(contact_person2_department).append("','").append(contact_person2_duty).append("','").append(contact_person2_sex).append("','").append(contact_person2_office_tel).append("','").append(contact_person2_home_tel).append("','").append(contact_person2_mobile).append("','").append(contact_person2_email).append("','").append(register).append("','").append(register_time).append("','").append(invoice_info).append("','").append(demand_products).append("','5','0','1','").append(logisticser).append("','").append(logisticser_ID).append("')").toString();
						logistics_db.executeUpdate(sql);
						CdefineUpdate CdefineUpdate = new CdefineUpdate();
						sql = CdefineUpdate.update("logistics_file", "provider_ID", provider_ID, request);
						logistics_db.executeUpdate(sql);
						response.sendRedirect((new StringBuilder("logistics/file/register_choose_attachment.jsp?provider_ID=")).append(provider_ID).toString());
					}
				} else
				{
					response.sendRedirect("logistics/file/register_draft_ok.jsp?finished_tag=1");
				}
				logistics_db.commit();
				logistics_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
